package file;

/**
 * 文件在邏輯Block的索引id
 */
public class BlockId {

    private String filename;
    private int blknum;

    public BlockId(String filename, int blknum) {
        this.filename = filename;
        this.blknum = blknum;
    }

    public String fileName() {
        return filename;
    }

    public int number() {
        return blknum;
    }

    @Override
    public  boolean equals(Object obj) {
        if (!(obj instanceof BlockId)) {
            return false;
        }
        BlockId blockId = (BlockId) obj;

        return this.blknum == blockId.blknum && this.filename == blockId.filename;
    }

    @Override
    public String toString() {
        String result = String.format("[file %s, block %d]", this.filename, this.blknum);
        return result;
    }

    @Override
    public int hashCode() {
        return toString().hashCode();
    }
}
